package main

import (
	"fmt"
	"os"
	"runtime"
	"strconv"
	"time"
)

const version = "1.0.4"
const server = "10.10.67.49"

func init() {
	err := os.MkdirAll("/var/run/tdclient/", 0755)
	if err != nil {
		fmt.Println("create pid dir error > ", err.Error())
		return
	}
	fd, err := os.Create("/var/run/tdclient/tdclient.pid")
	if err != nil {
		fmt.Println("create pid file error > ", err.Error())
		return
	}
	defer fd.Close()
	fd.WriteString(strconv.Itoa(os.Getpid()))
}

func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	InitLog()
	go checkVersion()
	//每分钟更新一次配置
	PullConfig()
	go func() {
		for {
			PullConfig()
			time.Sleep(60 * time.Second)
		}
	}()
	//循环执行插件
	go host.Run()
	//启动tcpserver
	go sendHeartbeat()
	StartTcpServe()
	//	c:=InitSignal()
	//	HandleSignal(c)
}
